﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace GSF.Objects
{
    class Wave
    {
        int m_numOfEnemies;
        int m_waveNumber;
        float m_spawnTimer;
        int m_enemiesSpawned;
        Game m_game;
        bool m_enemyAtEnd;
        bool m_spawningEnemies;
        public List<Enemy> m_enemies;
        Terrains m_terrain;
        public bool RoundOver
        {
            get { return m_enemies.Count == 0 && m_enemiesSpawned == m_numOfEnemies; }
        }
        public List<Enemy> Enemies
        {
            get { return m_enemies; }
        }
        public Wave(Game game, int NumberOfEnemies, Terrains terrain)
        {
            m_enemies = new List<Enemy>();
            m_numOfEnemies = NumberOfEnemies;
            m_terrain = terrain;
            m_game = game;
            m_enemiesSpawned = 0;
            m_spawnTimer = 0;
            m_spawningEnemies = true;

        }
        void addEnemy()
        {
            m_enemies.Add(new Enemy(m_game, ResourceMgr.Instance.getEnemy(0).path,
                  ResourceMgr.Instance.getEnemy(0).rows, ResourceMgr.Instance.getEnemy(0).cols, m_terrain.WayPoints));
            m_spawnTimer = 0;
            m_enemiesSpawned++;
        }
        public void Update(GameTime gameTime)
        {
            //nếu sinh đủ số lượng lính thì ngưng
            if (m_enemiesSpawned == m_numOfEnemies)
                m_spawningEnemies = false;

            if (m_spawningEnemies)
            {
                m_spawnTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;
                if (m_spawnTimer > 2)
                    addEnemy();
            }
            
        }
    }
}
